package com.qf.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * @Description:
 * @Author: xbb
 * @Date:2020/4/21
 */
@Configuration
public class RabbitMQConfig {

    @Value("${netty.port}")
    private Integer port;

    @Bean
    public Queue queue(){
        return new Queue("ws_queue_"+port);
    }

    @Bean
    public FanoutExchange fanoutExchange(){
        return new FanoutExchange("wx_exchange");
    }

    @Bean
    public Binding queueExchange(){
        return BindingBuilder.bind(queue()).to(fanoutExchange());
    }
}
